define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefined, Backend, Table, Form) {

    var Controller = {
        index: function () {
            // 初始化表格参数配置
            Table.api.init({
                extend: {
                    index_url: 'reorder/index' + location.search,
                    add_url: 'reorder/add',
                    edit_url: 'reorder/edit',
                    del_url: 'reorder/del',
                    multi_url: 'reorder/multi',
                    import_url: 'reorder/import',
                    table: 'reorder',
                }
            });

            var table = $("#table");

            // 初始化表格
            table.bootstrapTable({
                url: $.fn.bootstrapTable.defaults.extend.index_url,
                pk: 'id',
                sortName: 'id',
                columns: [
                    [
                        {checkbox: true},
                        {field: 'id', title: __('Id')},
                        {field: 'account', title: __('Account'), operate: 'LIKE'},
                        {field: 'ive_sn', title: __('Ive_sn'), operate: 'LIKE'},
                        {field: 'title', title: __('Title'), operate: 'LIKE'},
                        {field: 'game', title: __('Game'), operate: 'LIKE'},
                        {field: 'area', title: __('Area'), operate: 'LIKE'},
                        {field: 'server', title: __('Server'), operate: 'LIKE'},
                        {field: 'cross', title: __('Cross'), operate: 'LIKE'},
                        {field: 'type_name', title: __('Type_name'), operate: 'LIKE'},
                        {field: 'num', title: __('Num')},
                        {field: 'price', title: __('Price'), operate:'BETWEEN'},
                        {field: 'mobile', title: __('Mobile'), operate: 'LIKE'},
                        {field: 'invite', title: __('Invite'), operate: 'LIKE'},
                        {field: 'status', title: __('Status')},
                        {field: 'createtime', title: __('Createtime'), operate:'RANGE', addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime},
                        {field: 'personal.id', title: __('Personal.id')},
                        {field: 'personal.account', title: __('Personal.account'), operate: 'LIKE'},
                        {field: 'personal.nickname', title: __('Personal.nickname'), operate: 'LIKE'},
                        {field: 'personal.pass', title: __('Personal.pass'), operate: 'LIKE'},
                        {field: 'personal.salt', title: __('Personal.salt'), operate: 'LIKE'},
                        {field: 'personal.paypass', title: __('Personal.paypass'), operate: 'LIKE'},
                        {field: 'personal.mobile', title: __('Personal.mobile'), operate: 'LIKE'},
                        {field: 'personal.qq', title: __('Personal.qq'), operate: 'LIKE'},
                        {field: 'personal.balance', title: __('Personal.balance'), operate:'BETWEEN'},
                        {field: 'personal.jy_balance', title: __('Personal.jy_balance'), operate:'BETWEEN'},
                        {field: 'personal.email', title: __('Personal.email'), operate: 'LIKE'},
                        {field: 'personal.createtime', title: __('Personal.createtime'), operate:'RANGE', addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime},
                        {field: 'personal.ip', title: __('Personal.ip'), operate: 'LIKE'},
                        {field: 'personal.switch', title: __('Personal.switch'), table: table, formatter: Table.api.formatter.toggle},
                        {field: 'personal.weight', title: __('Personal.weight')},
                        {field: 'personal.is_real', title: __('Personal.is_real')},
                        {field: 'personal.id_card', title: __('Personal.id_card'), operate: 'LIKE'},
                        {field: 'personal.name', title: __('Personal.name'), operate: 'LIKE'},
                        {field: 'personal.zfb_name', title: __('Personal.zfb_name'), operate: 'LIKE'},
                        {field: 'personal.zfb_code', title: __('Personal.zfb_code'), operate: 'LIKE'},
                        {field: 'personal.safe', title: __('Personal.safe')},
                        {field: 'personal.type', title: __('Personal.type')},
                        {field: 'personal.token', title: __('Personal.token'), operate: 'LIKE'},
                        {field: 'personal.sex', title: __('Personal.sex')},
                        {field: 'personal.birthday', title: __('Personal.birthday'), operate: 'LIKE'},
                        {field: 'personal.urgency_phone', title: __('Personal.urgency_phone'), operate: 'LIKE'},
                        {field: 'personal.urgency_qq', title: __('Personal.urgency_qq'), operate: 'LIKE'},
                        {field: 'personal.online', title: __('Personal.online')},
                        {field: 'personal.avatar', title: __('Personal.avatar'), operate: 'LIKE', events: Table.api.events.image, formatter: Table.api.formatter.image},
                        {field: 'personal.logintime', title: __('Personal.logintime'), operate:'RANGE', addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime},
                        {field: 'personal.rztime', title: __('Personal.rztime'), operate:'RANGE', addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime},
                        {field: 'personal.video', title: __('Personal.video'), operate: 'LIKE'},
                        {field: 'personal.hold_card', title: __('Personal.hold_card'), operate: 'LIKE'},
                        {field: 'personal.auth_status', title: __('Personal.auth_status')},
                        {field: 'personal.auth_desc', title: __('Personal.auth_desc'), operate: 'LIKE'},
                        {field: 'personal.shopset', title: __('Personal.shopset')},
                        {field: 'receiving.id', title: __('Receiving.id')},
                        {field: 'receiving.uid', title: __('Receiving.uid')},
                        {field: 'receiving.rece_sn', title: __('Receiving.rece_sn'), operate: 'LIKE'},
                        {field: 'receiving.game_id', title: __('Receiving.game_id')},
                        {field: 'receiving.game', title: __('Receiving.game'), operate: 'LIKE'},
                        {field: 'receiving.area_id', title: __('Receiving.area_id')},
                        {field: 'receiving.area', title: __('Receiving.area'), operate: 'LIKE'},
                        {field: 'receiving.server_id', title: __('Receiving.server_id')},
                        {field: 'receiving.server', title: __('Receiving.server'), operate: 'LIKE'},
                        {field: 'receiving.cross_id', title: __('Receiving.cross_id')},
                        {field: 'receiving.cross', title: __('Receiving.cross'), operate: 'LIKE'},
                        {field: 'receiving.goods_type', title: __('Receiving.goods_type')},
                        {field: 'receiving.type_name', title: __('Receiving.type_name'), operate: 'LIKE'},
                        {field: 'receiving.title', title: __('Receiving.title'), operate: 'LIKE'},
                        {field: 'receiving.image', title: __('Receiving.image'), operate: false, events: Table.api.events.image, formatter: Table.api.formatter.image},
                        {field: 'receiving.num', title: __('Receiving.num')},
                        {field: 'receiving.price', title: __('Receiving.price'), operate:'BETWEEN'},
                        {field: 'receiving.min', title: __('Receiving.min')},
                        {field: 'receiving.max', title: __('Receiving.max')},
                        {field: 'receiving.specs', title: __('Receiving.specs'), operate: 'LIKE'},
                        {field: 'receiving.ask', title: __('Receiving.ask'), operate: 'LIKE'},
                        {field: 'receiving.mobile', title: __('Receiving.mobile'), operate: 'LIKE'},
                        {field: 'receiving.qq', title: __('Receiving.qq'), operate: 'LIKE'},
                        {field: 'receiving.jy_time', title: __('Receiving.jy_time'), operate: 'LIKE'},
                        {field: 'receiving.coin_type', title: __('Receiving.coin_type'), operate: 'LIKE'},
                        {field: 'receiving.createtime', title: __('Receiving.createtime'), operate:'RANGE', addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime},
                        {field: 'receiving.status', title: __('Receiving.status')},
                        {field: 'receiving.role_account', title: __('Receiving.role_account'), operate: 'LIKE'},
                        {field: 'receiving.role_level', title: __('Receiving.role_level')},
                        {field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, formatter: Table.api.formatter.operate}
                    ]
                ]
            });

            // 为表格绑定事件
            Table.api.bindevent(table);
        },
        add: function () {
            Controller.api.bindevent();
        },
        edit: function () {
            Controller.api.bindevent();
        },
        api: {
            bindevent: function () {
                Form.api.bindevent($("form[role=form]"));
            }
        }
    };
    return Controller;
});